import Vuex from 'vuex'
import Vue from 'vue'
const actions={
    jia:function(context,value){
        context.commit('JIA',value)
    },
    jian:function(context,value){
context.commit('JIAN',value)
    },
jiaOdd:function(context,value){
    if(context.state.sum%2!==0){
context.commit('JIA_ODD',value)
}
},
jiaWait:function(context,value){
    setTimeout(()=>{
        context.commit('JIA_WAIT',value)
    },1000)
},
}
const mutations={
    JIA(state,value){
        state.sum+=value
    },
    JIAN(state,value){
        state.sum-=value
    },
    JIA_ODD(state,value){
            state.sum+=value
    },
    JIA_WAIT(state,value){
            state.sum+=value
    }
}
const state={
    sum:0,
    where:'北京',
    what:'调酒'
}
const getters={
    bigSum:function(state){
        return state.sum*10
    }
}
Vue.use(Vuex)
export default new Vuex.Store({
    actions,
    mutations,
    state,
    getters
})